import matplotlib.pyplot as plt
import copy
csfont = {'fontname':'Times New Roman'}

Y_P ,Y_L = [], []
#RMSD-pro
X, Y = [], []
for line in open('./rmsd-pro.xvg','r', encoding='UTF-8'):
    if (line[0] != "#") & (line[0] != "@") :
        values = [float(s) for s in line.split()]
        X.append(values[0])
        Y.append(values[1])
plt.figure(figsize=(9, 4))
plt.plot(X, Y, color='black', linestyle='solid',linewidth="0.6")
plt.title("RMSD Protein", fontsize=16,**csfont)
plt.xlabel("Time (ns)",fontsize=14,**csfont)
plt.ylabel("RMSD (nm)",fontsize=14,**csfont)
plt.savefig("rmsd-pro.tiff",dpi=900)
Y_P = copy.deepcopy(Y)

#RMSD-lig
X, Y = [], []
for line in open('./rmsd-lig.xvg','r', encoding='UTF-8'):
    if (line[0] != "#") & (line[0] != "@") :
        values = [float(s) for s in line.split()]
        X.append(values[0])
        Y.append(values[1])
plt.figure(figsize=(9, 4))
plt.plot(X, Y, color='black', linestyle='solid',linewidth="0.6")
plt.title("RMSD Ligand", fontsize=16,**csfont)
plt.xlabel("Time (ns)",fontsize=14,**csfont)
plt.ylabel("RMSD (nm)",fontsize=14,**csfont)
plt.savefig("rmsd-lig.tiff",dpi=900)
Y_L = copy.deepcopy(Y)

#RMSD-complex
X, Y_C= [], []
for line in open('./rmsd-complex.xvg','r', encoding='UTF-8'):
    if (line[0] != "#") & (line[0] != "@") :
        values = [float(s) for s in line.split()]
        X.append(values[0])
        Y_C.append(values[1])
plt.figure(figsize=(9, 4))
plt.plot(X, Y_C ,color='black', linestyle='solid',linewidth="0.6")
plt.title("RMSD Complex", fontsize=16,**csfont)
plt.xlabel("Time (ns)",fontsize=14,**csfont)
plt.ylabel("RMSD (nm)",fontsize=14,**csfont)
plt.savefig("RMSD-complex.tiff",dpi=900)

#RMSD-merge
plt.figure(figsize=(9, 4))
plt.plot(X, Y_P ,color='black', linestyle='solid',linewidth="0.6")
plt.plot(X, Y_L ,color='red', linestyle='solid',linewidth="0.6")
plt.plot(X, Y_C ,color='blue', linestyle='solid',linewidth="0.6")
plt.title("RMSD Merge", fontsize=16,**csfont)
plt.xlabel("Time (ns)",fontsize=14,**csfont)
plt.ylabel("RMSD (nm)",fontsize=14,**csfont)
plt.savefig("RMSD-merge.tiff",dpi=900)


#Gyrate
X, Y = [], []
for line in open('./gyrate-pro.xvg','r', encoding='UTF-8'):
    if (line[0] != "#") & (line[0] != "@") :
        values = [float(s) for s in line.split()]
        X.append(values[0]/1000)
        Y.append(values[1])
plt.figure(figsize=(9, 5))
plt.plot(X, Y, color='black', linestyle='solid',linewidth="0.6")
plt.title("Gyrate", fontsize=16,**csfont)
plt.xlabel("Time (ns)",fontsize=14,**csfont)
plt.ylabel("Rg (nm)",fontsize=14,**csfont)
plt.savefig("gyrate.tiff",dpi=900)

#SASA
X, Y = [], []
for line in open('./sasa-pro.xvg','r', encoding='UTF-8'):
    if (line[0] != "#") & (line[0] != "@") :
        values = [float(s) for s in line.split()]
        X.append(values[0])
        Y.append(values[1])
plt.figure(figsize=(9, 5))
plt.plot(X, Y, color='black', linestyle='solid',linewidth="0.6")
plt.title("SASA", fontsize=16,**csfont)
plt.xlabel("Time (ns)",fontsize=14,**csfont)
plt.ylabel("Area (nm^2)",fontsize=14,**csfont)
plt.savefig("SASA.tiff",dpi=900)


#HB
X, Y = [], []
for line in open('./hbond-pro-lig.xvg','r', encoding='UTF-8'):
    if (line[0] != "#") & (line[0] != "@") :
        values = [float(s) for s in line.split()]
        X.append(values[0])
        Y.append(values[1])
plt.figure(figsize=(6, 6))
plt.plot(X, Y, color='black', linestyle='solid',linewidth="0.6")
plt.title("Hbonds Number", fontsize=16,**csfont)
plt.xlabel("Time (ns)",fontsize=14,**csfont)
plt.ylabel("The number of hydrogen bonds",fontsize=14,**csfont)
plt.savefig("Hbond-number.tiff",dpi=900)


#RMSF
X, Y = [], []
for line in open('./rmsf-pro.xvg','r', encoding='UTF-8'):
    if (line[0] != "#") & (line[0] != "@") :
        values = [float(s) for s in line.split()]
        X.append(values[0])
        Y.append(values[1])
plt.figure(figsize=(9, 5))
plt.plot(X, Y, color='black', linestyle='solid',linewidth="0.6")
plt.title("RMSF", fontsize=16,**csfont)
plt.xlabel("Redius",fontsize=14,**csfont)
plt.ylabel("RMSF (nm)",fontsize=14,**csfont)
plt.savefig("RMSF.tiff",dpi=900)